package com.zyq.system.controller;

import com.zyq.common.entity.AclPermission;
import com.zyq.system.service.AclPermissionService;
import com.zyq.common.vo.Result;
import com.zyq.system.vo.FenRolePermissionVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/permission")
public class AclPermissionController {
    @Autowired
    private AclPermissionService aclPermissionService;

    @PostMapping("/confirmFenPermission")
    public Result<String> confirmFenPermission(@RequestBody FenRolePermissionVo fenRolePermissionVo){
        return aclPermissionService.confirmFenPermission(fenRolePermissionVo);
    }

    @ApiOperation(value = "查询角色所对应的权限信息")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "角色id" , name = "roleId")
    })
    @GetMapping("/findPermissionByRoleId/{roleId}")
    public Result<Map<String,Object>> findPermissionByRoleId(@PathVariable String roleId){
        return aclPermissionService.findPermissionByRoleId(roleId);
    }
    @RequestMapping("getAllPermission")
    public Result<List<AclPermission>> getAllPermissionMenu(){
        return aclPermissionService.getPermissionMenu();
    }
    @RequestMapping("/getByUserId/{id}")
    public Result<List<AclPermission>> getPermissionInfo(@PathVariable("id") String id){
        Result<List<AclPermission>> userPermission = aclPermissionService.getUserPermission(id);
        return userPermission;
    }
}
